
export COMPATIBAL_CHIP
export chipname

chipname = $(strip $(CHIPNAME))

ifeq (goldengate, $(filter $(chipname), goldengate))
COMPATIBAL_CHIP += goldengate
endif

ifeq (greatbelt, $(filter $(chipname), greatbelt))
COMPATIBAL_CHIP += greatbelt
endif

ifneq ($(findstring HOST_IS_LE, $(CTC_CFLAGS)),HOST_IS_LE)
ifeq ($(strip $(ARCH)),powerpc)
EXTRA_CFLAGS += -DHOST_IS_LE=0
EXTRA_CFLAGS += -DCTC_ARCH_PPC
endif

ifeq ($(strip $(ARCH)),mips)
ifeq ($(strip $(CPU)),ls2f)
EXTRA_CFLAGS += -DHOST_IS_LE=1
else
EXTRA_CFLAGS += -DHOST_IS_LE=0
endif
EXTRA_CFLAGS += -DCTC_ARCH_MIPS
endif

ifeq ($(strip $(ARCH)),freescale)
EXTRA_CFLAGS += -DHOST_IS_LE=0
EXTRA_CFLAGS += -DCTC_ARCH_PPC
endif

ifeq ($(strip $(ARCH)),arm)
EXTRA_CFLAGS = -DHOST_IS_LE=1
EXTRA_CFLAGS += -DCTC_ARCH_ARM
endif

ifeq ($(strip $(ARCH)),arm64)
EXTRA_CFLAGS = -DHOST_IS_LE=1
EXTRA_CFLAGS += -DCTC_ARCH_ARM64
endif

ifeq ($(strip $(ARCH)),um)
EXTRA_CFLAGS += -DHOST_IS_LE=1
endif

ifeq ($(strip $(ARCH)),x86)
EXTRA_CFLAGS += -DHOST_IS_LE=1
EXTRA_CFLAGS += -DCTC_ARCH_X86
endif
endif


ifeq ($(strip $(ARCH)),mips)
ifeq ($(strip $(CPU)),ls2f)
EXTRA_CFLAGS += -DDMA_MEM_MODE_PLATFORM
else
EXTRA_CFLAGS += -DDMA_MEM_MODE_PLATFORM
endif
endif

ifeq ($(strip $(ARCH)),arm)
EXTRA_CFLAGS += -Wno-date-time
endif

ifeq ($(strip $(ARCH)),arm64)
EXTRA_CFLAGS += -Wno-date-time -mcmodel=large -mpc-relative-literal-loads
endif

ifeq ($(strip $(MCHIP_SIM)), yes)
EXTRA_CFLAGS += -DMCHIP_SIM=1
else
EXTRA_CFLAGS += -DMCHIP_SIM=0
endif

#################################
#SDK_WORK_ENV
#0 - with no cmodel;
#1 - with  cmodel;
#################################

#################################
#SDK_WORK_PLATFORM
#0 - hardware platform ;
#1 - software simulation platform;
#################################

ifeq ($(strip $(BOARD)),ctc-sim)
EXTRA_CFLAGS += -DUSE_SIM_MEM
EXTRA_CFLAGS += -DSDK_WORK_ENV=1
EXTRA_CFLAGS += -DSDK_WORK_PLATFORM=1
EXTRA_CFLAGS += -DDRVIER_WORK_PLATFORM=1
endif

ifeq ($(strip $(BOARD)),linux-sim)
EXTRA_CFLAGS += -DUSE_SIM_MEM
EXTRA_CFLAGS += -DSDK_WORK_ENV=0
EXTRA_CFLAGS += -DSDK_WORK_PLATFORM=1
endif

ifeq ($(strip $(BOARD)),ctc-board)
EXTRA_CFLAGS += -DSDK_WORK_ENV=1
EXTRA_CFLAGS += -DSDK_WORK_PLATFORM=0
endif

ifeq ($(strip $(BOARD)),linux-board)
EXTRA_CFLAGS += -DSDK_WORK_ENV=0
EXTRA_CFLAGS += -DSDK_WORK_PLATFORM=0
EXTRA_CFLAGS += -DDRVIER_WORK_PLATFORM=0
endif

ifeq (l2, $(filter $(strip $(featureMode)), l2))
EXTRA_CFLAGS += -DFEATURE_MODE=1
else
	ifeq (l2l3, $(filter $(strip $(featureMode)), l2l3))
    EXTRA_CFLAGS += -DFEATURE_MODE=2
    else
    EXTRA_CFLAGS += -DFEATURE_MODE=0
    endif
endif

ifeq (greatbelt, $(filter $(chipname), greatbelt))
EXTRA_CFLAGS += -DGREATBELT
endif

ifeq (goldengate, $(filter $(chipname), goldengate))
EXTRA_CFLAGS += -DGOLDENGATE
endif

ifeq (duet2, $(filter $(chipname), duet2))
EXTRA_CFLAGS += -DDUET2
EXTRA_CFLAGS += -DTMX
endif

ifeq (arctic, $(filter $(chipname), arctic))
EXTRA_CFLAGS += -DARCTIC
EXTRA_CFLAGS += -DUSW
endif

ifeq (tsingma_mx, $(filter $(chipname), tsingma_mx))
EXTRA_CFLAGS += -DTSINGMA_MX
EXTRA_CFLAGS += -DTMX
endif

ifeq (tsingma_gx, $(filter $(chipname), tsingma_gx))
EXTRA_CFLAGS += -DTSINGMA_GX
EXTRA_CFLAGS += -DTMX
endif
ifeq (tsingma, $(filter $(chipname), tsingma))
EXTRA_CFLAGS += -DTSINGMA
EXTRA_CFLAGS += -DTMX
endif

ifeq (tsingma_ax, $(filter $(chipname),tsingma_ax))
EXTRA_CFLAGS += -DTSINGMA_AX
endif
ifeq ($(CTC_CLI_EN), yes)
EXTRA_CFLAGS += -DCTC_CLI_EN
endif
ifeq ($(CTC_PHY_EN), yes)
EXTRA_CFLAGS += -DCTC_PHY_EN
CPPFLAGS += -DCTC_MULTI_CLIENT_EN
endif
ifneq ($(strip $(VER)),r)
EXTRA_CFLAGS += -DSDK_IN_DEBUG_VER
endif

ifeq ($(strip $(EUNIT)), yes)
EXTRA_CFLAGS += -DE_UNIT
endif

ifeq ($(CTC_PHY_EN), yes)
EXTRA_CFLAGS += -I$(SDK_DIR)/phy_drv/include
EXTRA_CFLAGS += -DSDK_PHY
EXTRA_CFLAGS += -DSUPPORT_PHY_MARS
endif
ifeq ($(ASW_ALONE), yes)
EXTRA_CFLAGS += -DASW_ALONE
endif
# Only used for building sdk in kernel mode
#

EXTRA_CFLAGS += -DCOMP_CRC=1 -Wno-unused -Wno-strict-prototypes
EXTRA_CFLAGS += -DSDK_IN_KERNEL
EXTRA_CFLAGS += -I$(TOP_DIR)/include/
EXTRA_CFLAGS += -I$(M)/sal/include
EXTRA_CFLAGS += -I$(M)/app/usr
EXTRA_CFLAGS += -I$(M)/app
EXTRA_CFLAGS += -I$(M)/app/sample
EXTRA_CFLAGS += -I$(M)/app/config
EXTRA_CFLAGS += -I$(M)/dal/include
EXTRA_CFLAGS += -I$(M)/dal/src/linux_kernel
EXTRA_CFLAGS += -I$(M)/driver
EXTRA_CFLAGS += -I$(M)/core/api/include
EXTRA_CFLAGS += -I$(M)/core/common/include
EXTRA_CFLAGS += -I$(M)/core/init
EXTRA_CFLAGS += -I$(M)/core/switch
EXTRA_CFLAGS += -I$(M)/core/app
EXTRA_CFLAGS += -I$(M)/core
ifeq ($(USW),yes)
EXTRA_CFLAGS += -I$(M)/core/usw/include
EXTRA_CFLAGS += -I$(M)/core/usw/include/ctc_tmx
EXTRA_CFLAGS += -I$(M)/core/usw/include/ctc_at
EXTRA_CFLAGS += -I$(M)/core/usw/include/sys
EXTRA_CFLAGS += -I$(M)/ctccli/sdkcli/usw
EXTRA_CFLAGS += -I$(M)/dkits/usw
EXTRA_CFLAGS += -I$(M)/driver/api
endif

EXTRA_CFLAGS += $(foreach n, $(COMPATIBAL_CHIP), -I$(M)/core/$(n)/include)
EXTRA_CFLAGS += $(foreach n, $(COMPATIBAL_CHIP), -I$(M)/core/$(n)/include/ctc)
EXTRA_CFLAGS += $(foreach n, $(COMPATIBAL_CHIP), -I$(M)/core/$(n)/include/sys)
EXTRA_CFLAGS += $(foreach n, $(COMPATIBAL_CHIP), -I$(M)/ctccli/sdkcli/$(n))
EXTRA_CFLAGS += $(foreach n, $(COMPATIBAL_CHIP), -I$(M)/dkits/$(n))
EXTRA_CFLAGS += -I$(M)/libctccli/include
EXTRA_CFLAGS += -I$(M)/ctccli/sdkcli
EXTRA_CFLAGS += -I$(M)/ctc_shell
EXTRA_CFLAGS += -I$(M)/dkits
EXTRA_CFLAGS += -I$(M)/dkits/common
ifeq ($(ASW),yes)
EXTRA_CFLAGS += -I$(M)/core/asw/include
endif
EXTRA_CFLAGS += $(CTC_CFLAGS)

